package com.yocard.yxyd.others;

import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * Created on 2019/4/11.
 */
public class CommonTimer extends CountDownTimer {

    private TextView textView;
    private String text = "";

    public CommonTimer(long millisInFuture, long countDownInterval, TextView textView) {
        super(millisInFuture, countDownInterval);
        this.textView = textView;
    }

    public CommonTimer(long millisInFuture, long countDownInterval, TextView textView,String text) {
        super(millisInFuture, countDownInterval);
        this.textView = textView;
        this.text = text;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        textView.setText(millisUntilFinished / 1000 + "s"+text);
    }

    @Override
    public void onFinish() {
        textView.setEnabled(true);
        textView.setText("获取验证码");
    }
}
